﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace DxfMonitor.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "DxfFolders",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    FolderFull = table.Column<string>(type: "TEXT", nullable: true),
                    BaseDate = table.Column<DateTime>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DxfFolders", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "DxfFiles",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    FolderId = table.Column<int>(type: "INTEGER", nullable: false),
                    RelativePath = table.Column<string>(type: "TEXT", nullable: false),
                    ModifiedDate = table.Column<DateTime>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DxfFiles", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DxfFiles_DxfFolders_FolderId",
                        column: x => x.FolderId,
                        principalTable: "DxfFolders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "DxfPairs",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    Guid = table.Column<string>(type: "TEXT", nullable: false),
                    CurrentFolderId = table.Column<int>(type: "INTEGER", nullable: false),
                    LastFolderId = table.Column<int>(type: "INTEGER", nullable: false),
                    IsChecked = table.Column<bool>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DxfPairs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DxfPairs_DxfFolders_CurrentFolderId",
                        column: x => x.CurrentFolderId,
                        principalTable: "DxfFolders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_DxfPairs_DxfFolders_LastFolderId",
                        column: x => x.LastFolderId,
                        principalTable: "DxfFolders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_DxfFiles_FolderId",
                table: "DxfFiles",
                column: "FolderId");

            migrationBuilder.CreateIndex(
                name: "IX_DxfPairs_CurrentFolderId",
                table: "DxfPairs",
                column: "CurrentFolderId");

            migrationBuilder.CreateIndex(
                name: "IX_DxfPairs_LastFolderId",
                table: "DxfPairs",
                column: "LastFolderId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "DxfFiles");

            migrationBuilder.DropTable(
                name: "DxfPairs");

            migrationBuilder.DropTable(
                name: "DxfFolders");
        }
    }
}
